#ifndef PSO_TOOLS_HPP_
#	define PSO_TOOLS_HPP_

#	include <cstdlib>
#	include <cmath>

#	define PSO_MIN_POSITION	0.f
#	define PSO_MAX_POSITION	100.f

/*
struct PSOFloat
{
	uint16_t		pfData;
	
	PSOFloat()
	{
		pfData = 0;
	}
	
	PSOFloat	operator=(double inD)
	{
		unsigned short register p1;
		unsigned short register p2;
		
		p1 = floor(inD);
		p2 = floor(inD * 100.);
		p2 %= 100;
		pfData = p1;
		pfData <<= 8;
		pfData |= p2;
	}
	
	operator double()
	{
		unsigned short register	p1;
		unsigned short register p2;
		
		p1 = pfData;
		p1 >>= 8;
		p2 = pfData;
		p2 &= 0xFFFF;
		
		return (p1 + p2 * 0.01);
	}
};
*/

inline double		random_real()
{
	return ((double)rand() / (RAND_MAX));
}

inline double		random_position()
{
	return (random_real());
}



inline double		relative_distance(double x, double y, double x2, double y2)
{
	double 	dist_end = 0.;
	int		dist_d = 0;
	
	dist_end = sqrt(pow(x - x2, 2.) + pow(y - y2, 2.));
	dist_end *= 100.;
	dist_d = (int)floor(dist_end);
	dist_end = dist_d * 0.01;
    
	return (dist_end);
}


#endif
